﻿#include<iostream>
#include<string>
#include<cstdlib>
#include<vector>
#include"stack8.h"

int main()
{
	try {
		Stack<int> intStack;			//int栈
		Stack<float> floatStack;		//float栈

		//使用int栈
		intStack.push(42);
		intStack.push(7);

		//使用float栈
		floatStack.push(7.7);

		//不同类型的两个栈之间的赋值
		floatStack = intStack;

		//输出float栈
		std::cout << floatStack.top() << std::endl;
		floatStack.pop();
		std::cout << floatStack.top() << std::endl;
		floatStack.pop();
		std::cout << floatStack.top() << std::endl;
		floatStack.pop();
	}
	catch (std::exception const& ex)
	{
		std::cerr << "Exception: " << ex.what() << std::endl;
	}

	//使用 vector作为内部容器的int栈
	Stack<int, std::vector> vStack;
	vStack.push(42);
	vStack.push(7);
	std::cout << vStack.top() << std::endl;
	vStack.pop();
}